package org.hales.schedule;

import cn.hutool.core.date.DateTime;
import cn.hutool.core.date.DateUtil;
import cn.hutool.poi.excel.ExcelReader;
import cn.hutool.poi.excel.ExcelUtil;
import org.hales.dao.mpsql.CronJobMapper;
import org.hales.pojo.CronJob;
import org.hales.pojo.PetrolStation;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Component;

import java.util.*;
import java.util.stream.Collectors;

/**
 * @author 陈建康
 */
//@Component
public class SystemTaskGroup {
//    @Autowired
    private CronJobMapper cronJobMapper;

    //{秒数} {分钟} {小时} {日期} {月份} {星期} {年份(可为空)}
    //定时任务 每个月1号凌晨3点 清除6个月前的数据
    // @Scheduled(cron = "0 0 3 1 * *")
    public void clearLog() {
        try {
            CronJob job =  cronJobMapper.selectByJobName("clearLog");
//            logManageService.clearLog();
            System.out.println(DateUtil.now() + ">>>>>>>>清理日志成功>>>>>>>>");
        }
        catch (Exception e) {
            System.out.println(DateUtil.now() + ">>>>>>>>清理日志异常："+e.getMessage());
        }
    }

    public static void main(String[] args) {
        ExcelReader reader = ExcelUtil.getReader("D:\\Hales\\lvchuang\\德阳三期\\加油站\\旌湖-新建加油站在线监控信息表.xlsx");
        List<PetrolStation> all = reader.readAll(PetrolStation.class);
        all = all.stream().filter(e -> e.getMnCode() != null).collect(Collectors.toList());
        System.out.println(all);
    }

}
